<template>
  <div>
    <!-- 语音播报路径情况 -->
    <!-- 语音控件 -->
    <audio autoplay preload :src="pathAudio" id="mo_yuyin"></audio>
  </div>
</template>

<script>
export default {
  props: {},
  data() {
    return {
      // 语音合成src
      pathAudio: null
    };
  },
  computed: {},
  created() {},
  mounted() {
    // 储存audioDom
    this.$store.commit("saveAudioDom", document.getElementById("mo_yuyin"));
  },
  watch: {},
  methods: {
    // 语音合成
    audioAutoPlay(otext, ospd) {
      const self = this;

      this.Axios.get(
        `https://service.chaunve.com/TTSWebService.asmx/BaiduTTS?text=${otext}&spd=${ospd}`
      ).then(voice => {
        self.pathAudio = voice.data;

        setTimeout(() => {
          self.$store.state.audio.play();
        }, 0);
      });
    }
  },
  components: {}
};
</script>

<style lang='less'>
</style>
